<html>
<head>
<title> Linux Video Stream Processing Tool - Examples</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="keywords" content="DVD, digital video, DV, encoder, divx,
DivX;-), lame, source, posix, avifile, opendivx, codec, linux, AC3,
program stream, video, audio, transcode, decoder, stream, YV12">
</head>

<body bgcolor=#CDB5CD>


<a name=top></a>
<table cellspacing="10" cellpadding="0" border="0" width="100%">
  <tr>
    <td align=left valign="top" width=30% bgcolor="#a0a0a0">
    <table border="0" cellpadding="10" cellspacing="3" font size=+2 bgcolor="#ffffff" width=100%>
      <td align="left" bgcolor="#e9e9e9"> <FONT
      FACE="Lucida,Helvetica"> <font>Digital Video</font>
    </tr>
    <tr>
      <td>

	  This chapter gives an introduction to Digital Video
	  processing with transcode. Here is a list of features:

	  <ul>
	    <li> AVI-files with Digital Video streams can be
		 decoded with
		 <ul>
		   <li><i>libdv</i> (default)
		   <li><i>ffmpeg</i> (-x ffmpeg)
		 </ul>

	  <li> concatenating clips with directory mode and option "-i <i>direname</i>"
	      before processing.
	  <li> a couple of fast or high-quality de-interlace
	      <a href=filter.html#video>filters</a> available to
	       enhance the quality.
	  <li> support for encoding to DV with <i>libdv</i> as raw
	      stream or interleaved AVI-file.
	  <li> pass-through mode: raw DV -> AVI-file conversion.
	</ul>

	Unfortunately, while most linux player happily accept the AVI-DV files
	produced by <i>transcode</i>, the nonlinear DV video
	editor <a href=http://www.schirmacher.de/arne/kino/><i>kino</i></a>
	refuses to work with them.

	<ul>
	  <li> <a href="dv.html#dv"> <FONT FACE="Lucida,Helvetica">
	  Digital Video DV</font></a>
	  <ul>
	     <li><a href="dv.html#dv_avi"> <FONT FACE="Lucida,Helvetica">
		 AVI files</font></a>
	     <li><a href="dv.html#dv_dv"> <FONT FACE="Lucida,Helvetica">
		 DV streams</font></a>
	   </ul>
	   <p>
       <li> <a href="#pass"> <FONT FACE="Lucida,Helvetica">
	  pass-through mode</font></a> <p>
       <li> <a href="#interlace"> <FONT FACE="Lucida,Helvetica">
	   de-interlacing guide</font></a> <p>
       <li> <a href="#alias"> <FONT FACE="Lucida,Helvetica">
	   anti-aliasing guide</font></a>

      </td>
    </tr>
</table>
</table>


<a name=dv></a>
<table cellspacing="10" cellpadding="0" border="0" width="100%">
  <tr>
    <td align=left valign="top" width=30% bgcolor="#a0a0a0">
    <table border="0" cellpadding="10" cellspacing="3" font size=+2 bgcolor="#ffffff" width=100%>
      <td align="left" bgcolor="#e9e9e9">

      <font>Digital Video (DV)
	  ---> MPEG-4</font>
    </tr>
    <tr>
      <td>

	  Here is a 3 step guide to convert a DV tape to a compressed AVI
	  MPEG-4 movie clip under linux using <i>transcode</i>. For a
	   selection of a video codec implementation supported by
	   transcode consult the <a href=modules.html> modules</a> info-page.

	  <ul>
	    <li> You need Arne Schirmacher's nice tool <i>dvgrab</I>
		to transfer the DV tape to disk. Make sure, you use
		the "--format dv2" option and maybe "--autosplit" to split
		the tape into small pieces. Use AVI files, since
		libdv sound seems to be broken. Optionally, use <br><br>
		<FONT color=red> tcprobe -i&nbsp; file.avi <br><br>
		 </i> to find out important parameters: For example:

		 <p><code>

[tcprobe] RIFF data, AVI video
[avilib] V: 25.000 fps, codec=dvsd, frames=633, width=720, height=576 <br>
[avilib] A: 48000 Hz, format=0x01, bits=16, channels=2, bitrate=1536
		 kbps, <br>
[avilib]    633 chunks, 4861528 bytes <br>
[tcprobe] summary for test-2002.10.04_14-47-25.avi, (*) = not default, 0 = not detected<br>
import frame size: -g 720x576 [720x576] <br>
       frame rate: -f 25.000 [25.000] frc=3 <br>
      audio track: -a 0 [0] -e 48000,16,2 [48000,16,2] -n 0x1 [0x2000] (*)
                   bitrate=1536 kbps <br>
           length: 633 frames, frame_time=40 msec <br>
</code><p>

		 Fortunately, the auto-probing feature
		of <i>transcode</i> takes care of these details.
		 <br><br>

	     <li> To encode the clips, we have a number of options:

		 <ul>
		   <li> writing a shell script, that feeds transcode with each
		   file,
		   <li> using <i>avimerge</i> to create a single
		       input file,

		   <li> using the directory mode with option "-i". This
		       works only in connection with the import module <i>import_dv.so</i>.
		 </ul>

		 <a name=dv_avi><h3>AVI-file</h3></a>

		 Here,
		 we use a single AVI-file <i>file.avi</i> with "dvsd" codec
		 as an example: <p>


		 <table>
		   <tr>
		     <td align=left valign="top" bgcolor="#ccffcc">
		     transcode</td>

		     <td align=left valign="top" bgcolor="#ccffcc">
		     -i file.avi -x dv,avi</td>
		   </tr>

		   <tr><td></td>
		       <td align=left valign="top" bgcolor="#ccffcc">
		       -I 1 -C 1 -z -k  </td>
		  </tr>

	     <td></td><td align=left valign="top" bgcolor="#ccffcc">
		 -o file-divxmp3.avi -y divx4</td></tr>

	   </table>

	   <br>

	   We use <i>import_avi.so</i> to extract the audio,
	   which works flawless. Note that the audio is found in two
	   places in the AVI-file. Firstly, interleaved in the DV video
	   frame and secondly, the PCM audio track itself.
	   This makes it possible to use the import module "dv" for audio
	   extraction as long <i>libdv</i> is broken.<br>
	   Note: some non-dvgrab produced AVI-files may have the audio
	   ripped from the DV frames. In this case, you must use "-x
	   dv,avi" or "-x dv,X", were X is one of (raw,mp3,ac3).
<br>

	   You can also reduce
	   the picture to a quarter size "-r 2" to get rid of
	   the interlace artifacts and don't need the de-interlace
	   option "-I 1". This option is the fastes de-interlacing
	   available, but is a simple interpolation.
	   You might also want to try
	   out the anti-aliasing feature with "-C 1" to process the
	   whole frame but this is slow.
	   The option "-z -k" flips the frame and make the
	   necessary color space changes for the encoder.


	   <a name=dv_dv><h3>DV stream</h3></a>

	   Put all AVI-files or raw DV stream into a subdirectory,
	   e.g., named "tape/". <p>


	   <table>
	     <tr>
	       <td align=left valign="top" bgcolor="#ccffcc">
	       transcode</td>

	       <td align=left valign="top" bgcolor="#ccffcc">
	       -i tape/ </td>
	     </tr>

	     <tr><td></td>
		 <td align=left valign="top" bgcolor="#ccffcc">
		 -I 3 -C 2 -z -k  </td>
	   </tr>

       <td></td><td align=left valign="top" bgcolor="#ccffcc">
	   -o tape-divxmp3.avi -y divx4</td></tr>

     </table>

     <br>

     The necessary import module is autodetected. <i>tccat</i> extracts
     the video stream of all AVI-files and concatenates them together to
     make the clips appear as a single DV stream for <i>transcode</i>.

     Here, the de-interlace option "-I 3",
     which drops one half-frame and interpolates by zooming to full
     frame size and, in principle, removes the interlace artifacts. We also try
	   the anti-aliasing feature with "-C 2" to process the
	   full frame afterwards, but this is slow.
     <p>

 <li> Well, that's it. Use <i>avimerge</i> to glue the
     matching clips together and burn the resulting file
     to CD.
</ul>
</TV>
</table>
</table>


<a name=pass></a>
<table cellspacing="10" cellpadding="0" border="0" width="100%">
  <tr>
    <td align=left valign="top" width=30% bgcolor="#a0a0a0">
    <table border="0" cellpadding="10" cellspacing="3" font size=+2 bgcolor="#ffffff" width=100%>
      <td align="left" bgcolor="#e9e9e9">

      <font>pass-through mode</font>
    </tr>
    <tr>
      <td>
	   The pass-through mode is able to wrap raw Digital Video
	   streams into AVI-files with the following command. Note, that
	   the interleaved raw audio data can be transcoded to a separate
	   audio track with the codec of your choice. However, this
	   does not save space since Digital Video has identical frame
	   size independent of the presence of audio.

	   <p>
	   <code>
	   transcode -i raw.dv -P 1 -o raw.avi -y raw
	   </code>
	   <p>

	   The opposite way is achieved by:

	   <p>
	   <code>
	   tcextract -i raw.avi -x raw > raw.dv
	   </code>
	   <p>

</table>
</table>

<a name=interlace></a>
<table cellspacing="10" cellpadding="0" border="0" width="100%">
  <tr>
    <td align=left valign="top" width=30% bgcolor="#a0a0a0">
    <table border="0" cellpadding="10" cellspacing="3" font size=+2 bgcolor="#ffffff" width=100%>
      <td align="left" bgcolor="#e9e9e9">

      <font>de-interlacing guide</font>
    </tr>
    <tr>
      <td>

	  Underway.
	  Tilmann Bitterberg did some testing of de-interlace filters available in
	  transcode. You can view and read the result
	  <a href=http://tibit.org/video/> here</a>.
</table>
</table>


<a name=alias></a>
<table cellspacing="10" cellpadding="0" border="0" width="100%">
  <tr>
    <td align=left valign="top" width=30% bgcolor="#a0a0a0">
    <table border="0" cellpadding="10" cellspacing="3" font size=+2 bgcolor="#ffffff" width=100%>
      <td align="left" bgcolor="#e9e9e9">

      <font>anti-aliasing guide</font>
    </tr>
    <tr>
      <td>

	  Underway.

</table>
</table>


<!-- hhmts start -->
Last modified: Fri Dec  6 16:25:56 Europe/Berlin 2002
<!-- hhmts end -->

</body> </html>
